<%@page contentType="text/html; charset=utf-8"  isELIgnored="false"%>
<%
String agent = request.getHeader("user-agent"); 
System.out.println(agent);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>后台管理系统</title>
        <link rel="stylesheet" type="text/css" href="js/themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="js/themes/icon.css">
		<script type="text/javascript" src="js/jquery-2.2.1.min.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath }/js/locale/easyui-lang-zh_CN.js"></script>
		<style type="text/css">
			a{text-decoration:none;color:black;}
			body{background-color:#DDD;}
		</style>
        <script type="text/javascript">
         function check_f(){
	         console.log($("#userCode").val());
	         $.getJSON( "${pageContext.request.contextPath }/validLogin.do", { userCode: $("#userCode").val(),
	        	 userPwd: $("#userPwd").val(),ckcode:$("#ckcode").val() } )
	         .done(function( json ) {
	        	flag = json.flag;
	           console.log( "JSON Data: " + json.flag );
	        	if(flag==1){
	        		   $.messager.alert('提示','该用户不存在，请检查您输入的用户名');
	        	}else if(flag == 2){
	        		  $.messager.alert('提示','密码错误，请检查您的密码后重新输入');
	        	}else{
	        		location='${pageContext.request.contextPath }/index.do';
	        	}
	         })
	         .fail(function( jqxhr, textStatus, error ) {
	           var err = textStatus + ", " + error;
	           console.log( "Request Failed: " + err );
	       });
         }
         //
         function change_code() {
			$("#validCodeImgEl").attr("src",'${pageContext.request.contextPath }/kaptcha/img.do?date=2');
		 }
        </script>
</head>
<body>
<div style="margin:0 auto;width:800px;">
<div id="win" class="easyui-window" minimizable="false" maximizable="false"  collapsible="false"  title="登录窗口" style="width:400px;height:270px;">
    <form action="main.htm" method="post" style="padding:40px 20px 10px 80px;" name="login_f">
        <p>用户名:&nbsp;<input class="easyui-validatebox" type="text" id="userCode" name="userCode" required="true"/></p>
        <p>密&nbsp;&nbsp;&nbsp;码:&nbsp;<input class="easyui-validatebox"  id="userPwd" type="password" name="userPwd" required="true"></p>
        <p>验证码:&nbsp;<input class="easyui-validatebox" id="ckcode" type="text" id="n" name="ckcode" required="true" style="width:80px;"/>
        <img id="validCodeImgEl" src="${pageContext.request.contextPath }/kaptcha/img.do" 
        width="70" height="30" style="cursor: pointer;" onclick="change_code()"/></p>
        <div style="padding:5px;text-align:center;">
            <a href="#" class="easyui-linkbutton" icon="icon-ok" onclick="check_f()">登录</a>
            <a href="#" class="easyui-linkbutton" icon="icon-cancel" onclick="document.login_f.reset()">重置</a>
        </div>
    </form>
</div>
</div>

</body>
</html>
